home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / util / libs / MMULib.lha / MMULib / Lib_Sources / mu_loadlib.asm < prev    next >
Encoding:
Assembly Source File  |  1998-10-04  |  3.8 KB  |  111 lines

  1. ;*************************************************************************
  2. ;** mmu.library                                                         **
  3. ;**                                                                     **
  4. ;** a system library for arbitration and control of the MC68K MMUs      **
  5. ;**                                                                     **
  6. ;** © 1998 THOR-Software, Thomas Richter                                **
  7. ;** No commercial use, reassembly, modification without prior, written  **
  8. ;** permission of the authors.                                          **
  9. ;** Including this library in any commercial software REQUIRES a        **
  10. ;** written permission and the payment of a small fee.                  **
  11. ;**                                                                     **
  12. ;** This is an internal header file, do not depend on anything here.    **
  13. ;** Use the official include files.                                     **
  14. ;** Distributed only for the mmu.library development group for private  **
  15. ;** use.                                                                **
  16. ;**                                                                     **
  17. ;**---------------------------------------------------------------------**
  18. ;** Block: Load the MMU library for testing purposes                    **
  19. ;*************************************************************************
  20.  
  21. ;FOLD Includes
  22.         include inc:exec_lib.asm
  23.         include inc:dos_lib.asm
  24.         include inc:macros.asm
  25. ;ENDFOLD
  26. ;FOLD Structures
  27. ;*************************************************
  28. ;** The main structure for this                 **
  29. ;** little something                            **
  30. ;*************************************************
  31.         rsreset
  32. mn_SysBase:     rs.l 1
  33. mn_DosBase:     rs.l 1
  34. mn_MMUBase:     rs.l 1
  35. mn_Segment:     rs.l 1
  36. mn_len:         rs.b 0
  37. ;ENDFOLD
  38.  
  39.         section main_code,code
  40. ;FOLD Start
  41. ;*************************************************
  42. ;** Start                                       **
  43. ;*************************************************
  44. Start:
  45.         move.l ExecBase,a6
  46.         moveq #37,d0
  47.         lea MainBss,a5
  48.         move.l a6,mn_SysBase(a5)
  49.         lea DosName,a1
  50.         jsr OpenLibrary(a6)
  51.         move.l d0,mn_DosBase(a5)
  52.         beq.s .exit
  53.  
  54.         move.l d0,a6
  55.         move.l #LibrarySegment,d1
  56.         jsr LoadSeg(a6)
  57.         move.l d0,mn_Segment(a5)
  58.         beq.s .closeexit
  59.  
  60.         move.l d0,a0
  61.         move.l d0,d1
  62.         adda.l a0,a0
  63.         adda.l a0,a0
  64.         move.l -4(a0),d0                ;get size of the segment
  65.         lsr.l #1,d0                     ;in words
  66.         subq.l #4,d0                    ;size and BPTR doesn't count
  67.         addq.l #4,a0                    ;pointer to first code
  68.         do
  69.          cmp.w #$4afc,(a0)+             ;illegal ?
  70.          beq.s .found                   ;if so, found it
  71. .retry:
  72.          subq.l #1,d0                   ;count down
  73.         while.s ne
  74.         moveq #0,d0                     ;exit: resident tag not found
  75.         bra.s .unloadexit
  76. .found:
  77.         lea -2(a0),a1                   ;ptr to ResidentTag
  78.         cmp.l (a0),a1                   ;is this a resident tag?
  79.         bne.s .retry
  80.  
  81.         move.l mn_SysBase(a5),a6
  82.         jsr InitResident(a6)            ;initialize this thing
  83.         move.l d0,mn_MMUBase(a5)        ;must be initialized
  84.         beq.s .unloadexit
  85.  
  86.         move.l d0,a6
  87.         jsr -$12(a6)                    ;Expunge it
  88. .unloadexit:
  89.         move.l mn_DOSBase(a5),a6
  90.         move.l mn_Segment(a5),d1
  91.         jsr UnloadSeg(a6)
  92. .closeexit:
  93.         move.l mn_SysBase(a5),a6
  94.         move.l mn_DOSBase(a5),a1
  95.         jsr CloseLibrary(a6)
  96. .exit:
  97.         moveq #0,d0
  98.         rts
  99. ;ENDFOLD
  100.  
  101. ;FOLD Data
  102.         section main_data,data
  103.  
  104. DosName:        dc.b "dos.library",0
  105. LibrarySegment: dc.b "mmu.library",0
  106.  
  107.         section main_bss,bss
  108. MainBSS:        ds.b mn_len
  109.  
  110. ;ENDFOLD
  111.